using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

using miciv;
using micivCore.Xml;

namespace micivCore.Faction
{
    public class FactionManager : HashtableManager<string, Faction>
    {
        protected CoreContext m_coreContext;

        public FactionManager(CoreContext _coreContext)
        {
            this.m_coreContext = _coreContext;
        }

        public bool LoadConfig(string _strLocation)
        {
            _strLocation = this.m_coreContext.CoreManager.GetExistingFile(_strLocation);
            XmlDocument xmlDoc = this.m_coreContext.CoreManager.LoadXml(_strLocation, false);
            XmlTraverser xmlTraverser = new XmlTraverser(xmlDoc.DocumentElement);
            XmlListenerFaction factionCreator = new XmlListenerFaction();

            factionCreator.Initialize(this, this.m_coreContext, xmlTraverser);
            factionCreator.Attach();
            xmlTraverser.Traverse();
            factionCreator.Detach();

            return true;
        }
    }
}
